<?php

defined('_JEXEC') or die();

jimport( 'joomla.application.component.controller' ); 

class ApkipasControllerResources extends JController 
{
	
	protected $option;
	protected $controller;
	
	function __construct( $default = array()){
		$this->option = 'com_apkipas';
		$this->controller = 'resources';
		$this->layout = JRequest::getVar('layout') ;
		parent::__construct( $default );
	}

	function display()
	{
		switch($this->getTask()){
			case 'add':{
				JRequest::setVar( 'layout', 'form'  );
				JRequest::setVar( 'view'  , $this->controller);
			} 
			break;
			default:
				JRequest::setVar( 'view'  , $this->controller);
				break;
		}
		parent::display();
	}
	
	function save(){
		$post = JRequest::get('post');
		$model = $this->getModel('resources');
		$id = $model->save($post);
		if($id != 0){
			$this->setRedirect('index.php?option='.$this->option.'&view='.$this->controller,'Saved');
		}
		else{
			$this->setRedirect('index.php?option='.$this->option.'&view='.$this->controller,'Error');
		}
	}
}
